﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UWarrantyCardExList.aspx.cs"
    Inherits="IHISCETeim.Web.MachineSys.UserModel.UWarrantyCardExList" %>
<script type="text/javascript">
    $(document).ready(function () {
        $(".UWarrantyCardExListTree").find("a").dblclick(function () {
            navTab.openTab("UWarrantyCardExList", "UserModel/UWarrantyCardExList.aspx", { title: "用户通信录", fresh: true, data: { "ShowAgentName": $(this).attr("tname"), "IsVip": $("#UWarrantyCardExList_IsVip").attr("checked")} });

        })
        //代理商短信群发
        $("#UWarrantyCardExList_SendAgentSMS").click(function (event) {
            var $this = $(this);
            var title = $this.attr("title");
            var $smskey = encodeURI($("#UWarrantyCardExList_SMSTempList").val());
            if (!$selectagentname) {
                return false;
            }

            var $url = "sysAjaxDone.ashx?ajaxmethod=SendAgentSMSGroup&AgentName=" + encodeURI($selectagentname) + "&smskey=" + $smskey;
            if (title) {
                alertMsg.confirm(title, {
                    okCall: function () {
                        ajaxTodo($url, function (json) { DWZ.ajaxDone(json); });
                    }
                });

            } else {
                ajaxTodo($url);
            }
            event.preventDefault();

        })
        //用户短信群发
        $("#UWarrantyCardExList_SendCustomerSMS").click(function (event) {
            function _getIds(selectedIds) {
                var ids = "";
                navTab.getCurrentPanel().find("input:checked").filter("[name='" + selectedIds + "']").each(function (i) {
                    var val = $(this).val();
                    ids += i == 0 ? val : "," + val;
                });
                return ids;
            }
            var uwcids = _getIds("uwcids");
            if (!uwcids) {
                return false;
            }
            var $this = $(this);
            var title = $this.attr("title");
            var $smskey = encodeURI($("#UWarrantyCardExList_SMSTempList").val());
            var $url = "sysAjaxDone.ashx?ajaxmethod=SendCustomerSMSGroup&uwcids=" + encodeURI(uwcids) + "&smskey=" + $smskey;
            if (title) {
                alertMsg.confirm(title, {
                    okCall: function () {
                        ajaxTodo($url, function (json) { DWZ.ajaxDone(json); });
                    }
                });

            } else {
                ajaxTodo($url);
            }
            event.preventDefault();

        })

    })
    //所有已选中的代理商
    var $selectagentname = "<%=ShowAgentName %>";
    function UWarrantyCardExListTreeCheck() {
        var json = arguments[0], result = "";
        if (json.checked) {
            $(json.items).each(function (i) {
                // result += "<p>name:" + this.name + " value:" + this.value + " text: " + this.text + "</p>";
                $selectagentname += this.name + ",";
            });
        }
        else {
            $(json.items).each(function (i) {
                $selectagentname = $selectagentname.replace(this.name + ",", "");
            });
        }
        $("#UWarrantyCardExList_ShowAgentName").val($selectagentname);
    }
                </script>
<form id="pagerForm" method="post" action="UserModel/UWarrantyCardExList.aspx">
<input type="hidden" name="IsVip" value="<%=IsVip %>" />
<input type="hidden" name="ShowAgentName" value="<%=ShowAgentName %>" />
<input type="hidden" name="SerialNumber" value="<%=SerialNumber %>" />
<input type="hidden" name="IntoDateFrom" value="<%=IntoDateFrom %>" />
<input type="hidden" name="IntoDateTo" value="<%=IntoDateTo %>" />
<input type="hidden" name="orderField" value="<%=orderField %>" />
<input type="hidden" name="orderDirection" value="<%=orderDirection %>" />
<input type="hidden" name="pageNum" value="1" />
<input type="hidden" name="numPerPage" value="<%=numPerPage %>" />
</form>
<form id="form1" runat="server" method="post" action="UserModel/UWarrantyCardExList.aspx"
onsubmit="return navTabSearch(this);">
<div class="pageContent">

    <div class="panelBar" style="line-height: 23px; padding: 0px 5px;">
        <b>短信群发功能:</b> 第一步,请先选择短信模板:
        <select name="smstempletelist" id="UWarrantyCardExList_SMSTempList">
            <%=GetSMSTempleteList() %>
        </select>
        . 第二步,可按代理商分组来群发,或选择一些用户信息来群发
    </div>    
    <div class="agentlistdiv">
        <div class="panelBar" >
            <ul class="toolBar"  > 
                <li><a class="add" href="#" id="UWarrantyCardExList_SendAgentSMS" title="确定要对选中的代理商进行短信群发吗?" ><span>群发</span></a></li>
                <li style=" float:right;"><a href="#" class="closeselectagent delete"><span>确定选择</span></a></li>
            </ul>
        </div>                
        <div class="agentlisttreecon">
            <ul class="tree treeCheck UWarrantyCardExListTree" oncheck="UWarrantyCardExListTreeCheck">
                <%=GetAgentList()%>
            </ul>
        </div>
    </div>   
      
        <div class="searchBar">
             <input type="hidden" id="UWarrantyCardExList_ShowAgentName" name="ShowAgentName" value="<%=ShowAgentName %>" />
             <table class="searchContent"  >
                <tr>
                <td>
                    <b>查询条件：</b>
                </td>
                <td>                   
                    <a href="#"  class="openselectagent">选择代理商</a>
                </td>
                <td>
                    <input type="checkbox" id="UWarrantyCardExList_IsVip" name="IsVip" value="True" <%=IsVip?"checked":"" %> />只显示VIP用户
                </td>             
                <td>
                    机号:
                </td>
                <td>
                    <input type="text" name="SerialNumber" value="<%=SerialNumber %>"  style="width:80px;"/>
                </td>
                <td>
                    交机日期:从<input name="IntoDateFrom" class="date" style="width:80px;" />
                    到<input name="IntoDateTo" class="date" style="width:80px;" />
                </td>
                <td>
                    <div class="subBar">
                        <ul>
                            <li>
                                <div class="buttonActive">
                                    <div class="buttonContent">
                                        <button type="submit">
                                            检索</button></div>
                                </div>
                            </li>
                        </ul>
                    </div>
                </td>
            </tr>                        
            </table>
        </div>  
        
    
    <div class="panelBar">
        <ul class="toolBar"  >            
            <% if (HasPower(IHISCETeim.Web.Permission.修改)){%>
            <li><a class="edit" href="UserModel/UWarrantyCardExEdit.aspx?UWCID={sid_user}" target="navTab" title="修改通信录" rel="UWarrantyCardExEdit"><span>编辑/查看</span></a></li>
            <%} %>
            <li><a title="确实要对这些用户发送短信吗?" class="icon" id="UWarrantyCardExList_SendCustomerSMS"><span>批量发送</span></a></li>
        </ul>
        </div>
    <asp:repeater id="rpMenu" runat="server">
        <HeaderTemplate>
        <table class="table" width="100%" layoutH="125">
        <thead>
            <tr  > 
                 <th width="25"><input type="checkbox" group="uwcids" class="checkboxCtrl"></th>               
                <th width="80"  orderField="MachineType" class="asc">
                    机型
                </th>
                <th  orderField="SerialNumber" class="asc" width="80">
                    机号
                </th>
                <th orderField="IntoDate" class="asc" width="100">
                    交机日期
                </th>
                <th width="100">
                    客户姓名
                </th>
                
                <th width="100">
                    客户手机
                </th>
                <th >
                    地址
                </th>   
                <th  width="60">
                    VIP
                </th>         
                <th  width="100">
                    代理商
                </th>             
            </tr>
        </thead>
        <tbody>
        </HeaderTemplate>
        <ItemTemplate>
            <tr target="sid_user" rel="<%# Eval("UWCID") %>">
             <td><input name="uwcids" value="<%# Eval("UWCID") %>" type="checkbox"/></td>
				<td><%# Eval("MachineType")%></td>
				<td>
                <%# Eval("SerialNumber")%>
                </td>
				<td><%# Convert.ToDateTime(Eval("IntoDate")).ToString("yyyy-MM-dd")%></td>
				<td><%# Eval("CustomerName")%></td>
				
                <td><%# Eval("CustomerMobile")%></td>
				<td><%# Eval("CustomerAddress")%></td>
                <td><%# Eval("IsVip")%></td>
                 <td>
                    <%# Eval("AgentName")%>
                </td>    
			</tr>
        </ItemTemplate>
        <FooterTemplate>
        </tbody>
    </table>
    </FooterTemplate> </asp:repeater>
    <div class="panelBar">
        <div class="pages">
            <span>显示</span>
            <select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
                <%=SetnumPerPage() %>
            </select>
            <span>条，共<%=TotalCount%>条</span>
        </div>
        <div class="pagination" targettype="navTab" totalcount="<%=TotalCount%>" numperpage="<%=numPerPage %>"
            pagenumshown="10" currentpage="<%=pageNum %>">
        </div>
    </div>
   
</div>
</form>
